package com.zim.aliot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.aliyuncs.DefaultAcsClient;
import com.zim.aliot.config.AliIotConfig;
import com.zim.aliot.listener.StartCommandLineRunner;
import com.zim.aliot.util.ResultVOUtils;
import com.zim.aliot.vo.ResultVO;

@RestController
public class IndexController {
    @Autowired
    private AliIotConfig aliIotConfig;
    
    @Autowired
    private StartCommandLineRunner startCommandLineRunner; 
    
    @Autowired
    private DefaultAcsClient defaultAcsClient;
    
    @RequestMapping(value = { "/", "/checkHeartbeat" })
    public ResultVO<String> Index() {
        ResultVO<String> resultVO = new ResultVO<>();
        resultVO.setCode(0);
        resultVO.setMsg("心跳正常");
        System.out.println(aliIotConfig);
        return resultVO;
    }
    
    @RequestMapping("test/acs")
    public ResultVO<Object> IotAcsClient() {
        
        System.out.println(defaultAcsClient);
        return ResultVOUtils.success();
    }
    
    @RequestMapping("mns/stop")
    public ResultVO<Object> mnsStop() {
        startCommandLineRunner.stop();
    
        return ResultVOUtils.success();
    }
}
